package com.example.safeassistan.train.index;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.safeassistan.R;
import com.example.safeassistan.base.BaseVPFragment;
import com.example.safeassistan.message.activity.Activity_Message;
import com.example.safeassistan.train.activity.ActivityKnowledgeBase;
import com.example.safeassistan.train.activity.TrainExamList;
import com.example.safeassistan.train.activity.TrainSimulateList;
import com.example.safeassistan.widget.MyRelativeLayout;

public class TrainIndex extends BaseVPFragment implements View.OnClickListener {
    private Context context;
    private View view;
    private ImageView ivMsg;
    private MyRelativeLayout rlKnowledgeBase,rlSimulateAnswer,rlFormalAnswer;
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rlKnowledgeBase:
                ActivityKnowledgeBase.actionStart(context);
                break;
            case R.id.ivMsg:
                Activity_Message.actionStart(context);
                break;
            case R.id.rlSimulateAnswer:
                TrainSimulateList.actionStart(getContext());
                break;
            case R.id.rlFormalAnswer:
                TrainExamList.actionStart(getContext());
                break;
        }
    }

    @Override
    protected void onFragmentVisibleChange(boolean isVisible) { }

    @Override
    protected void onFragmentFirstVisible() { }

    public static TrainIndex newInstance(String content) {
        Bundle arguments = new Bundle();
        arguments.putString("string", content);
        TrainIndex fl = new TrainIndex();
        fl.setArguments(arguments);
        return fl;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(R.layout.train_index, container, false);
            context = getActivity();
            initView();
        }
        return view;
    }

    public void initView(){
        ivMsg=view.findViewById(R.id.ivMsg);
        ivMsg.setOnClickListener(this::onClick);
        rlKnowledgeBase=view.findViewById(R.id.rlKnowledgeBase);
        rlKnowledgeBase.setOnClickListener(this::onClick);
        rlSimulateAnswer=view.findViewById(R.id.rlSimulateAnswer);
        rlSimulateAnswer.setOnClickListener(this::onClick);
        rlFormalAnswer=view.findViewById(R.id.rlFormalAnswer);
        rlFormalAnswer.setOnClickListener(this::onClick);
    }
}